package ru.stepuk.modeller.generators;

/**
 *
 * @author ivan
 */
public class MultiplicativeGenerator implements RandomNumberGenerator {

    private static final int A = 630360016;
    private static final int M = 2147483647;
    private double previous;
    private int initialValue;

    public MultiplicativeGenerator(int initialValue) {
        if (initialValue < 0) {
            throw new IllegalArgumentException();
        }
        this.previous = this.initialValue = initialValue;
    }

    public double nextValue() {
        previous = (A * previous) % M;
        return previous / M;
    }

    public int getInitialValue() {
        return initialValue;
    }
}
